package com.pattern.singleton;
/*
* ThreadLocal 线程单例模式   在一个线程中 可用保证是单例的单个线程中是唯一的，天生的线程安全。
* */
public class ThreadLocalSingleton {
    private static final ThreadLocal<ThreadLocalSingleton> threadlocal=new ThreadLocal<ThreadLocalSingleton>(){
        @Override
        protected ThreadLocalSingleton initialValue() {
            return new ThreadLocalSingleton();
        }
    };
    public static ThreadLocalSingleton getInstance(){
        return threadlocal.get();
    }
}
